//
//  HROrderApplyCell.m
//  haierapp
//
//  Created by gaotangzhang on 14-8-18.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "HROrderApplyCell.h"

#import "HROrderProductInfo.h"

@implementation HROrderApplyCell

- (void)awakeFromNib
{
    self.btnAfterSale.layer.cornerRadius = 5;
    self.btnAfterSale.layer.borderWidth = 1;
    self.btnAfterSale.layer.borderColor = [UIColor redColor].CGColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(id)init{
    self=[[[NSBundle mainBundle]loadNibNamed:@"HROrderApplyCell" owner:self options:nil]objectAtIndex:0];
    self.btnAfterSale.layer.cornerRadius = 5;
    self.btnAfterSale.layer.borderWidth = 1;
    self.btnAfterSale.layer.borderColor = [UIColor redColor].CGColor;
    return self;
}

-(void)configWithData:(id)data{
    HROrderProductInfo *product=(HROrderProductInfo *)data;
    
    NSURL *imgUrl=[NSURL URLWithString:product.productLinker];
    [self.goodsImageView setImageWithURL:imgUrl placeholderImage:[UIImage imageNamed:IMAGENAME_PLACE_HODLE]];
    self.goodsName.text=product.productTitle;
    self.goodsType.text=@"";
    
    //产品规格
    NSString *params=@"";
    
    for (HRProSpeInfo *info in product.productClassify) {
        params=[NSString stringWithFormat:@"%@:%@;%@",info.name,info.value,params];
    }
    
    self.goodsCount.text=params;
    
    self.goodsPrice.text=[NSString stringWithFormat:@"￥%@",product.unitPrice];
    
    self.goodsCount.text=@"";
    
    if (product.productNum!=nil) {
        self.goodsCount.text=[NSString stringWithFormat:@"×%@",product.productNum];
    }else if(product.goodsAmount!=nil){
        self.goodsCount.text=[NSString stringWithFormat:@"%@",product.goodsAmount];
    }
}

-(void)configWithData:(id)data showAfertSale:(BOOL)show{
    self.btnAfterSale.hidden = !show;
    [self configWithData:data];
}

//申请售后
- (IBAction)applyAfterSale:(id)sender {
    if (_applyAfterSale) {
        _applyAfterSale();
    }
}

-(void)setShowBottomLine:(BOOL)isShow{
    if (isShow) {
        self.bottomLine.hidden=NO;
    }else{
        self.bottomLine.hidden=YES;
    }
}

@end
